/**
 * Copyright (c) 2019 AsHacker All rights reserved.
 *
 * http://www.ashacker.com
 *
 * 版权所有，侵权必究！
 */

package io.renren.modules.app.controller;

import com.alibaba.fastjson.JSON;
import io.renren.common.utils.R;
import io.renren.modules.lucky.entity.AppSysLogoEntity;
import io.renren.modules.lucky.entity.AppSysModelEntity;
import io.renren.modules.lucky.service.AppSysLogoService;
import io.renren.modules.lucky.service.AppSysModelService;
import io.renren.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * APP首页界面
 *
 * @author Chen chenchen@ashacker.com
 */
@RestController
@RequestMapping("/app")
@Api("APP首页界面")
public class AppMainController extends AbstractController {
	
	@Autowired
	private AppSysModelService appSysModelService;

	@Autowired
	private AppSysLogoService appSysLogoService;

	/**
	 * 开机广告、首页轮播图、智能弹窗
	 * type=1\2\3
	 */
	@GetMapping("getMainLogoList")
	@ApiOperation("广告汇总")
	public R getMainLogoList(@RequestParam String logo_type) {

		logger.info("getMainLogoList方法执行开始：传入参数为   "+logo_type);

		String logoType = logo_type==null?"":logo_type;

		// 获取广告列表信息
		List<AppSysLogoEntity> list = appSysLogoService.getSysLogoByType(logoType);

		Map<String, Object> map = new HashMap<>();
		// map.put("expire", jwtUtils.getExpire());
		map.put("list", list);

		logger.info("getMainLogoList方法执行结束：返回值为   "+ JSON.toJSONString(map));

		return R.ok(map);
	}

	/**
	 * 获取上下角标列表信息
	 * type=top\bottom
	 * @return
	 */
	@GetMapping("getMainButtonList")
	@ApiOperation("首页角标列表")
	public R getMainButtonList(@RequestParam String model_type) {

		logger.info("getMainButtonList方法执行开始：传入参数为   "+model_type);

		String modelType = model_type==null?"":model_type;

		// 获取主界面角标信息
		List<AppSysModelEntity> list = appSysModelService.getSysModelByType(modelType);
		Map<String, Object> map = new HashMap<>();
		map.put("list", list);

		logger.info("getMainButtonList方法执行结束：返回值为   "+ JSON.toJSONString(map));

		return R.ok(map);
	}

}
